import request from '@/config/axios'

export interface LandingPageVO {
  id: number
  title: string
  content: string
  device: string
  components: string
  status: number
  remark: string
  createTime: Date
}

export interface LandingPagePageReqVO extends PageParam {
  title?: string
  status?: number
  createTime?: Date[]
}

export interface LandingPageForm {
  id?: number
  title: string
  content: string
  device: string
  components: string
  status: number
  remark?: string
}

/** 落地页 API 地址 */
const API = {
  Page: '/weiyi/landing-page/page',
  Detail: '/weiyi/landing-page/get?id=',
  Create: '/weiyi/landing-page/create',
  Update: '/weiyi/landing-page/update',
  Delete: '/weiyi/landing-page/delete?id=',
  UpdateStatus: '/weiyi/landing-page/update-status?id={}&status={}'
}

/** 获取落地页分页列表 */
export const getLandingPagePage = (params: LandingPagePageReqVO) => {
  return request.get<PageResult<LandingPageVO>>({ url: API.Page, params })
}

/** 获取落地页详情 */
export const getLandingPage = (id: number) => {
  return request.get<LandingPageVO>({ url: API.Detail + id })
}

/** 创建落地页 */
export const createLandingPage = (data: LandingPageForm) => {
  return request.post({ url: API.Create, data })
}

/** 更新落地页 */
export const updateLandingPage = (data: LandingPageForm) => {
  return request.put({ url: API.Update, data })
}

/** 删除落地页 */
export const deleteLandingPage = (id: number) => {
  return request.delete({ url: API.Delete + id })
}

/** 更新落地页状态 */
export const updateLandingPageStatus = (id: number, status: number) => {
  return request.put({ 
    url: API.UpdateStatus.replace('{}', id.toString()).replace('{}', status.toString())
  })
} 